package com.s3.khospitalds.controller;

import com.s3.khospitalds.common.R;
import com.s3.khospitalds.common.ResponseEntity;
import com.s3.khospitalds.entity.Shiftlist;
import com.s3.khospitalds.service.ShiftlistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 想要告诉你
 * @CreateTime: 2025/3/7 14:58
 * @Description: 医生轮班类
 * @Version: 1.0
 */
@RestController
@CrossOrigin(origins = "*")
public class ShiftlistController {
    @Autowired
    private ShiftlistService shiftlistService;
    //查看医生轮班信息
    @GetMapping("/getShiftlist")
    public ResponseEntity selectShiftlist(Integer pageNum, Integer pageSize, String searchDepartment, String searchName, String searchTimes) {
        pageNum = pageNum == null ? 1 : pageNum;
        pageSize = pageSize == null ? 10 : pageSize;
        searchDepartment = searchDepartment == null ? "" : searchDepartment;
        searchName = searchName == null ? "" : searchName;
        searchTimes = searchTimes == null ? "" : searchTimes;
        return shiftlistService.selectShiftlist(pageNum, pageSize, searchDepartment, searchName, searchTimes);
    }

    //新增医生轮班信息
    @PostMapping("/insertShiftlist")
    public R insertShiftlist(@RequestBody Shiftlist shiftlist) {
        return new R().addData("id",shiftlistService.insertShiftlist(shiftlist));
    }
    //修改医生轮班信息
    @PostMapping("/updateShiftlist")
    public R updateShiftlist(@RequestBody Shiftlist shiftlist) {
        return new R().addData("id",shiftlistService.updateShiftlist(shiftlist));
    }
    //删除医生轮班信息
    @PostMapping("/deleteShiftlist")
    public R deleteShiftlist(@RequestBody Integer id) {
        return new R().addData("id",shiftlistService.deleteShiftlist(id));
    }
}
